<?php
	//Show modal retport truyen
	if($_GET['get_modal_truyen_report'] == 1){
		$modal = '<div role="dialog" id="modal_truyen_report" class="modal" style="display:none;">
				<div class="modal-dialog modal-wide" id="modal_report_inner">
	
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					        Lý do báo xấu
						</div>
						<div class="modal-body" id="modal-content">
					        <form id="report_form" class="userPostForm" role="form" method="post" enctype="multipart/form-data">
								<div class="form-group">
									<div class="row">
										<div class="col-md-2">
											<label for="txt_report_content">Nội dung</label>
										</div>
										<div class="col-md-10">
											<textarea class="form-control" placeholder="Nhập nội dung báo xấu..." id="txt_report_content" rows="3"></textarea>
									</div>
									</div>
								</div>
	
								<div class="form-group">
									<div class="row">
										<div class="col-md-2"></div>
										<div class="col-md-10">
											<button type=submit class="btn btn-primary mySubmit submit_truyen_report" data-href="'.$id.'" data-rel="'.$rel.'" id="submit_report_'.$id.'">
												<i class="glyphicon glyphicon-hand-up"></i> <span>Xác nhận</span>
											</button>
										</div>
									</div>
								</div>
							</form>
						</div>
					</div><!-- /.modal-content -->
				</div>
			</div>';
		echo $modal;
		exit();
	}
	
	
	//Get truyen history modal and data
	if($_GET['getStoryHistory'] == 1){
		?>
      		<div role="dialog" id="modal_story_history" class="modal">
				<div class="modal-dialog modal-wide" id="modal_report_inner">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
					        <h2>Lịch sử đọc truyện <span class="show_history_number"><?php echo '(' . count($_COOKIE['tc']) . ')'; ?></span></h2>
						</div>
						<div class="modal-body" id="modal-content">
		<?php 
		if($_COOKIE['tc']){
			//$_COOKIE['tc'] = stripslashes($_COOKIE['tc']);
			$_COOKIE['tc'] = array_reverse($_COOKIE['tc']);
			$count = 1;
			foreach($_COOKIE['tc'] as $key => $value){


				if(get_magic_quotes_gpc() == 0){
					$value = json_decode($value, true);
				}else{
					$value = json_decode(stripslashes($value), true);
				}

			?>
				<div class="wrap_each_history">
					<span class="badge"><?= $count; ?></span>
					<a class="history_ten_truyen" href="<?= $value['truyen_link']; ?>"><?= $value['truyen'] ?></a> - 
					<a class="history_ten_chuong" href="<?= $value['chuong_link']; ?>"><?= $value['tenchuong']; ?></a>
				</div>
				
			<?php 
			$count++;
			}
		}else{
			echo '<div class="alert alert-warning">Bạn chưa có lịch sử đọc truyện.</div>';
		}
		?>
						</div>
					</div>
				</div>
			</div>
			<script type="text/javascript">
				$('#modal_story_history').modal();
			</script>
		<?php 
		exit();
	}//End of get history
